Minor doc improvements on our hodgepodge of C89 and Qt.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 27 Jan 2015 04:33:45 +0000 (04:33 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 27 Jan 2015 04:33:45 +0000 (04:33 +0000)
Whitespace changes, mostly trailing whitespace.

13 files changed:
gpsbabel/README.contrib
gpsbabel/html.cc
gpsbabel/humminbird.cc
gpsbabel/mkshort.cc
gpsbabel/mmo.cc
gpsbabel/mynav.cc
gpsbabel/navilink.cc
gpsbabel/osm.cc
gpsbabel/tomtom.cc
gpsbabel/transform.cc
gpsbabel/unicsv.cc
gpsbabel/util.cc
gpsbabel/waypt.cc

index 3f865f2b0933103aae902e4384b6669a629b5eba..17ac821ac91db2f649ef399273f26df301c95984 100644 (file)
@@ -12,17 +12,20 @@ functions.
 You may find format_skeleton.c and filter_skeleton.c in the source tree
 to be helpful examples. Just add meat!
 
-Prefer Qt objects/classes to ISO C/POSIX services.  QStrings are reference
-counted, implicitly shared, and have a robust supporting library.  QDateTime
-supports sub-second time and a range of dates far beyond 1970->2038 and are
-much more pleasant to work with than ctime/mktime/struct tm.  "But I see
-strcpy, sprintf, and struct tm and such in the code!"  It's true; GPSBabel 
-is a tenured project of well over ten years.  We have code that predates
-our move to C++/Qt that isn't well tested or has a low payoff to modernize
-and uses old constructs.  Our actively maintained/strategic formats like
-GPX and KML tend to be better examples of modern programming, using things
-like XmlStreamWriter instead of fprintf and are generally better models to
-follow.
+Prefer Qt objects/classes to ISO C/POSIX services.  
+ * QStrings are reference counted, implicitly shared, and have a 
+   robust supporting library.  
+ * QDateTime supports sub-second time and a range of dates far 
+   beyond 1970->2038 and are much more pleasant to work with 
+   than ctime/mktime/struct tm.  
+ * QXmlStreamReader and Writer eliminate the need to explictly quote data.
+"But I see strcpy, sprintf, and struct tm and such in the code!"  It's
+true; GPSBabel is a tenured project of well over ten years.  We have 
+code that predates our move to C++/Qt that isn't well tested or has a 
+low payoff to modernize and uses old constructs.  Our actively 
+maintained/strategic formats like GPX and KML tend to be better 
+examples of modern programming and are generally better models to
+follow. New code shouldn't be using xstrdup and gbfprintf.
 
 Compilers complain for a reason.   Code shouldn't emit warnings.
 
@@ -37,6 +40,7 @@ prefer:
        int
        mumble(int whatever)
        {
+        <2spaces>char* pointers_clump_to_type;
        <2spaces>if (whatevever) {
        <4spaces>return blah;
        <2spaces>}
index f208e7cb43612d1462aae7925ac8bbad06f343be..91b52a663b2f6696df337a0ab1248a956f6af839 100644 (file)
@@ -258,10 +258,10 @@ data_write(void)
   gbfprintf(file_out, "<head>\n");
   gbfprintf(file_out, " <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n");
 
-  // Don't write this line when running test suite.  Actually, we should 
+  // Don't write this line when running test suite.  Actually, we should
   // probably not write this line at all...
   if (!getenv("GPSBABEL_FREEZE_TIME")) {
-  gbfprintf(file_out, " <meta name=\"Generator\" content=\"GPSBabel %s\">\n", gpsbabel_version);
+    gbfprintf(file_out, " <meta name=\"Generator\" content=\"GPSBabel %s\">\n", gpsbabel_version);
   }
   gbfprintf(file_out, " <title>GPSBabel HTML Output</title>\n");
   if (stylesheet) {
index b9380230ac4070cb282383981c8f9b66bc72c8a3..3d70ebcfd70df103c8a313a79be421f26d079540 100644 (file)
@@ -286,7 +286,7 @@ humminbird_read_wpt(gbfile* fin)
   wpt = new Waypoint;
 
   // Could probably find a way to eliminate the alloc/copy.
-  char *s = xstrndup(w.name, sizeof(w.name));
+  chars = xstrndup(w.name, sizeof(w.name));
   wpt->shortname = s;
   xfree(s);
 
@@ -361,7 +361,7 @@ humminbird_read_route(gbfile* fin)
           rte = route_head_alloc();
           route_add_head(rte);
           // TODO: find a way to eliminate the copy.
-          char *s = xstrndup(hrte.name, sizeof(hrte.name));
+          chars = xstrndup(hrte.name, sizeof(hrte.name));
           rte->rte_name = s;
           xfree(s);
           /* rte->rte_num = hrte.num + 1; only internal number */
@@ -429,7 +429,7 @@ humminbird_read_track(gbfile* fin)
   track_add_head(trk);
 
   // TODO: find a way to eliminate the copy.
-  char *s = xstrndup(th.name, sizeof(th.name));
+  chars = xstrndup(th.name, sizeof(th.name));
   trk->rte_name = s;
   xfree(s);
   trk->rte_num  = th.trk_num;
index e7ffec15183ed1ccdf8c63ce4bcf8b3dec46f3b4..aa75e7f180812e8780b56f9f6833afa0b0a5e419 100644 (file)
@@ -577,7 +577,7 @@ mkshort(short_handle h, const char* istring)
 QString
 mkshort(short_handle h, const QString& istring)
 {
-  char *t =  mkshort(h, CSTR(istring));
+  chart =  mkshort(h, CSTR(istring));
   QString r(t);
   xfree(t);
   return r;
index d3fe913d11d06eca679c20849633e85ac20896d5..f2d071f049585d433f07754f770411ee731d5944 100644 (file)
@@ -313,7 +313,7 @@ mmo_free_object(mmo_data_t* data)
     xfree(data->name);
   }
   if ((data->type == wptdata) && (data->refct == 0)) {
-    delete (Waypoint*)data->data;
+    delete(Waypoint*)data->data;
   }
   xfree(data);
 }
@@ -945,7 +945,7 @@ mmo_finalize_rtept_cb(const Waypoint* wptref)
     mmo_data_t* data;
     Waypoint* wpt2;
 
-// This code path isn't tested in anything we have and I have  No Idea 
+// This code path isn't tested in anything we have and I have  No Idea
 // what it was trying to do.  Throw a hard error to force the hand of
 // getting a sample file.
     abort();
@@ -1122,7 +1122,8 @@ mmo_writestr(const char* str)
 }
 
 static void
-mmo_writestr(const QString& str) {
+mmo_writestr(const QString& str)
+{
   // If UTF-8 is used instgead of Latin1, we fail in weird ways.
   mmo_writestr(str.toLatin1().constData());
 }
@@ -1214,7 +1215,7 @@ mmo_write_obj_head(const char* sobj, const char* name, const time_t ctime,
 static void
 mmo_write_wpt_cb(const Waypoint* wpt)
 {
-  QString str; 
+  QString str;
   QString cx;
   int objid;
   time_t time;
index 62576d08ff6bcd50dbbc76bbf30d09c860f218b3..3a660c55147f753f252c90e6c749df1373ccc1fd 100644 (file)
@@ -3,7 +3,7 @@
 
     Copyright (c) 2014 Ralf Horstmann <ralf@ackstorm.de>
     Copyright (C) 2014 Robert Lipe, robertlipe+source@gpsbabel.org
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -58,36 +58,43 @@ mynav_rd_line(QString line)
 
   if (global_opts.debug_level > 1) {
     qDebug() << "line: " << line;
-    for (int i = 0; i < fields.size(); i++)
+    for (int i = 0; i < fields.size(); i++) {
       qDebug() << "field" << i << fields.at(i);
+    }
   }
 
   // don't consider lines without latitude/longitude
-  if (fields.size() <= fld_lat)
+  if (fields.size() <= fld_lat) {
     return;
+  }
 
   // only type 1 and type 5 lines contain coordinates
   bool ok = false;
-  int val_type = fields.at(fld_type).trimmed().toInt(&ok);  
-  if (!ok)
+  int val_type = fields.at(fld_type).trimmed().toInt(&ok);
+  if (!ok) {
     return;
-  if (val_type != 1 && val_type != 5)
+  }
+  if (val_type != 1 && val_type != 5) {
     return;
+  }
 
   // This field is not present in .trc files, only in .ftn, so
   // ignore line if present and != 1
   if (fields.size() > fld_gps_valid) {
     int val_gps_valid = fields.at(fld_gps_valid).trimmed().toInt(&ok);
-    if (!ok || val_gps_valid != 1)
+    if (!ok || val_gps_valid != 1) {
       return;
+    }
   }
 
   double val_lon = fields.at(fld_lon).trimmed().toDouble(&ok) / 3600000.0;
-  if (!ok)
+  if (!ok) {
     return;
+  }
   double val_lat = fields.at(fld_lat).trimmed().toDouble(&ok) / 3600000.0;
-  if (!ok)
+  if (!ok) {
     return;
+  }
 
   Waypoint* wpt = new Waypoint;
   wpt->latitude = val_lat;
@@ -95,16 +102,18 @@ mynav_rd_line(QString line)
 
   if (fields.size() > fld_altitude) {
     double val_alt = fields.at(fld_altitude).trimmed().toDouble(&ok);
-    if (ok)
+    if (ok) {
       wpt->altitude = val_alt;
+    }
   }
 
   if (fields.size() > fld_timestamp) {
     int val_time = fields.at(fld_timestamp).trimmed().toInt(&ok);
-    if (ok)
+    if (ok) {
       wpt->SetCreationTime(val_time);
+    }
   }
-  
+
   track_add_wpt(mynav_track, wpt);
 }
 
@@ -127,7 +136,7 @@ mynav_rd_deinit(void)
   gbfclose(fin);
 }
 
-static void 
+static void
 mynav_rd(void)
 {
   QString buff;
index 0139c4a26f9142d1e663e2377d696b456262aa54..c586c65702fdd07ca111090cd1417ad39c841663 100644 (file)
@@ -847,7 +847,7 @@ navilink_decode_logpoint(const unsigned char* buffer)
 
   waypt->hdop = ((unsigned char)buffer[0]) * 0.2f;
   waypt->sat = buffer[1];
-  waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4), 
+  waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4),
                          decode_sbp_msec(buffer + 2));
   decode_sbp_position(buffer + 12, waypt);
   WAYPT_SET(waypt, speed, le_read16(buffer + 24) * 0.01f);
index c8699781b04cc131ec035f58b8ffd0f50df47e21..d5f91c86dcc1ddadf8d6ef81a02c77d539ebef63 100644 (file)
@@ -631,7 +631,7 @@ osm_way_tag(xg_string args, const QXmlStreamAttributes* attrv)
     rte->rte_name = str;
 
     wpt->shortname = str;
-   // The remaining cases only apply to the center node
+    // The remaining cases only apply to the center node
   } else if ((ikey = osm_feature_ikey(key)) >= 0) {
     wpt->icon_descr = osm_feature_symbol(ikey, CSTR(value));
   } else if (key == "note") {
index ce9cc786aa580bb2e20503ae97a97bcde691074b..2247b215efb1f66beaa900cfc439b62c81d43958 100644 (file)
@@ -356,7 +356,8 @@ write_blocks(gbfile* f, struct blockheader* blocks)
 
 static struct blockheader*
 compute_blocks(struct hdr* start, int count,
-               double minlon, double maxlon, double minlat, double maxlat) {
+               double minlon, double maxlon, double minlat, double maxlat)
+{
   struct blockheader* newblock;
 
   newblock = (struct blockheader*)xcalloc(sizeof(*newblock), 1);
index c625ed97498bb678ea79e43a470878f690309b35..1fa9b7de5993958aa4691f64413f668877373607 100644 (file)
@@ -114,7 +114,7 @@ transform_rte_disp_hdr_cb(const route_head* rte)
   if (current_target == 'T') {
     current_trk = route_head_alloc();
     track_add_head(current_trk);
-     if (!rte->rte_name.isEmpty()) {
+    if (!rte->rte_name.isEmpty()) {
       current_trk->rte_desc = QString("Generated from route %1").arg(rte->rte_name);
       current_trk->rte_name = rte->rte_name; /* name the new trk */
     }
index 016cea94a89c2ea5428a15b9ff94162c41987492..b6723917ed06bbb04fe3687ba77ed9999673e6f2 100644 (file)
@@ -307,7 +307,7 @@ unicsv_parse_gc_id(const QString& str)
   int res = 0;
   const QString kBase35 = "0123456789ABCDEFGHJKMNPQRTVWXYZ"; //  ILOSU are omitted.
   if (str.startsWith("GC")) {
-    int base35 = str.size() > 6; // above GCFFFF? 
+    int base35 = str.size() > 6; // above GCFFFF?
     QString s = str.mid(2);
     while (!s.isEmpty()) {
       res = res * 16 + kBase35.indexOf(s[0]);
@@ -429,7 +429,7 @@ unicsv_parse_status(const QString& str)
       str == "0") {
     return status_false;
   }
-return status_unknown;
+  return status_unknown;
 }
 
 static QDateTime
@@ -628,7 +628,7 @@ unicsv_parse_one_line(char* ibuf)
   double swiss_easting = unicsv_unknown;
   double swiss_northing = unicsv_unknown;
   int checked = 0;
-  time_t date = -1; 
+  time_t date = -1;
   time_t time = -1;
   int usec = -1;
   char is_localtime = 0;
index 214fd1f5956b9eaa20d46b009ff8502a1217b746..4058eeff4147c680160f63e8e477ac0e762fc77a 100644 (file)
@@ -284,7 +284,7 @@ xasprintf(QString* strp, const char* fmt, ...)
   va_list args;
   int res;
   va_start(args, fmt);
-  char *cstrp;
+  charcstrp;
   res = xvasprintf(&cstrp, fmt, args);
   *strp = cstrp;
   xfree(cstrp);
@@ -533,7 +533,7 @@ str_match(const char* str, const char* match)
       if (*m == '\0') {
         return 0;  /* incomplete escape sequence */
       }
-      /* pass-through next character */
+    /* pass-through next character */
 
     default:
       if (*m != *s) {
@@ -783,7 +783,7 @@ mkgmtime(struct tm* t)
   result += t->tm_min;
   result *= 60;
   result += t->tm_sec;
-  return(result);
+  return (result);
 }
 
 /*
@@ -1174,7 +1174,7 @@ rot13(const QString& s)
   static const QChar Z('Z');
   QString r = s;
   int i = r.length();
-  while(i--) {
+  while (i--) {
     QChar letter = r[i].toUpper();
     if (letter >= A && letter <= M) {
       r[i] = QChar(r[i].toLatin1() + 13);
@@ -1493,10 +1493,10 @@ strip_html(const utf_string* in)
 {
 #if 0
   // If we were willing to link core against QtGui (not out of the question)
-  // we could just do...and either decide whether to add handling for [IMG] 
+  // we could just do...and either decide whether to add handling for [IMG]
   // or just say we don't do that any more.
   QTextDocument doc;
-  doc.setHtml( in->utfstring );
+  doc.setHtml(in->utfstring);
   return xstrdup(CSTR(doc.toPlainText().simplified()));
 #else
   char* outstring, *out;
index aa80eb11ae6b8c290cf863bad3b37af933091a49..3cdbcdbe025503614ef39c2ffeb1e3d154f8b943 100644 (file)
@@ -100,11 +100,11 @@ waypt_add(Waypoint* wpt)
   }
 
   if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
-    Fatal() << wpt->session->name 
-            << "Invalid latitude" << lat_orig << "in waypoint" 
+    Fatal() << wpt->session->name
+            << "Invalid latitude" << lat_orig << "in waypoint"
             << wpt->shortname;
   if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
-    Fatal() << "Invalid longitude" << lon_orig << "in waypoint" 
+    Fatal() << "Invalid longitude" << lon_orig << "in waypoint"
             << wpt->shortname;
 
   /*